#!/bin/sh
top[0]=002203
top[1]=002204
top[2]=002205
top[3]=002206
top[4]=002207
top[5]=002208
top[6]=002209
top[7]=002210
top[8]=002211
top[9]=002212
top[10]=002213
top[11]=002214
top[12]=002215
top[13]=002216
top[14]=002217
top[15]=002218
top[16]=002219
top[17]=002220
top[18]=002221
top[19]=002222
top[20]=002223
top[21]=002224
top[22]=002225
top[23]=002226
top[24]=002227
top[25]=002228
top[26]=002229
top[27]=002230
top[28]=002231
top[29]=002232
top[30]=002233
top[31]=002234
top[32]=002235
top[33]=002236
top[34]=002237
top[35]=002238
top[36]=002239
top[37]=002240
top[38]=002241
top[39]=002242
top[40]=002243
top[41]=002244
top[42]=002245
top[43]=002246
top[44]=002247
top[45]=002248
top[46]=002249
top[47]=002250
top[48]=002251
top[49]=002252
top[50]=002253
top[51]=002254
top[52]=002255
top[53]=002256
top[54]=002258
top[55]=002259
top[56]=002260
top[57]=002261
top[58]=002262
top[59]=002263
top[60]=002264
top[61]=002265
top[62]=002266
top[63]=002267
top[64]=002268
top[65]=002269
top[66]=002270
top[67]=002271
top[68]=601186
top[69]=601766
top[70]=601898
top[71]=601899
top[72]=601958

##########################
# SMW.stock.sh
# 
#
# Created by [CGM]sgxiao on 08-12-19.
# Copyright 2008 CGM. All rights reserved.
############################

days[0]=2
days[1]=5
days[2]=10
days[3]=50
days[4]=100
days[5]=150
days[6]=200


startYear=1994
endYear=2007
DATA=data
RESULT=result.doc
filename=$1
AWKSRC=SMW.awk
TEMP=temp.divide
FINAL=SMW
TOP=temp.to_sh
STOCK=stock

i=0
while [ $i -le 72 ]
do
	echo ${top[i]}
	#mkdir ${top[i]}
	startYear=1994
	while [ ${startYear} -le ${endYear} ]
	do

	########
echo "BEGIN {
	FS=\"\\\\t\"
}
\$2 ~ /${top[i]}/{
	printf(\"%s\\\\t%s\\\\t%s\\\\n\", \$1, \$7, \$8);
}
END{}

" > ${AWKSRC}
	awk -f ${AWKSRC} ${startYear}.${DATA} >> ${top[i]}.${STOCK} 

	########	
		
		startYear=$((startYear+1))	
	done
	#mv ${top[i]}.${STOCK} ${top[i]}/
	
	j=0
	while [ $j -le 6 ]
	do
		java SimpleMovingAverage ${top[i]}.${STOCK} ${days[j]} > ${top[i]}.${STOCK}.${days[j]} 
		j=$((j+1))
	done

	i=$((i+1))
done



#mv *.data ../

